package com.contact;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

import com.android.ocean.util.common.StringUtil;
import com.http.FriendAddByNumTask;
import com.matang.R;
import com.modle.User;
import com.util.AppUtil;
import com.util.UserUtil;
/**
 * 
 * @ClassName:UserAddActivity
 * @Description:TODO通过艺人号添加user
 * @author zhuw
 * @date 2013-9-4 下午7:32:22
 */
public class UserAddActivity extends BaseActivity implements OnClickListener ,FriendAddByNumTask.CallBack{
	Button submitBtn;
	EditText yrNumEt;
	String yrNumStr;
	User user;
	@Override
	protected void onCreate(Bundle savedInstanceState) {

		super.onCreate(savedInstanceState);
		setContentView(R.layout.act_user_add);
		init();
	}

	void init() {
		mContext = UserAddActivity.this;
		findViews();
		initPaneData();

	}

	public void initPaneData() {
		super.initPaneData();
		user=UserUtil.readUser();
		submitBtn.setOnClickListener(this);
		header.headTitleTv.setText("添加好友");
	}

	@Override
	protected void findViews() {
		super.findViews();
		submitBtn = (Button) findViewById(R.id.submit_btn);
		yrNumEt=(EditText)findViewById(R.id.yrh_tv);
		
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.submit_btn: {
			submit();
			break;
		}

		}

	}
   void submit(){
	   yrNumStr=yrNumEt.getText().toString();
	   if(StringUtil.isNull(yrNumStr)){
		   AppUtil.tsMsg(mContext, "好友号不能为空");
	   }else{
		   
		   addFriend();
	   }
	   
   }
	
	void addFriend(){
		showProgressDialog("好友添加中");
		new FriendAddByNumTask(this).execute(user.id,yrNumStr);
	}
	
	
	@Override
	public void procError(String msg) {
		dismissProgressDialog();
		AppUtil.tsMsg(mContext, msg);
		
	}

	@Override
	public void procAddFriendByNum(String data) {
	dismissProgressDialog();
	yrNumStr=null;
	yrNumEt.setText("");
	AppUtil.tsMsg(mContext, data);
		
	}

}
